#ifndef _KLAS_MATRIX3_HPP_
#define _KLAS_MATRIX3_HPP_

#include "../Platform.hpp"
#include "../math/Vector2.hpp"

#include <cmath>

namespace klas
{
  namespace math
  {
    //! A utility class to manipulate 3D matrices representing 2D transformations.
    class KLAS_API Matrix3
    {
    public:

      //! Build an identity matrix.
      Matrix3();

      //! Build a matrix from nine elements.
      Matrix3(double a00, double a01, double a02,
              double a10, double a11, double a12,
              double a20, double a21, double a22);

      //! Build a matrix from specified parameters.
      /*! \param translation Translation offset
          \param rotation Rotation angle in degrees.
          \param scale Scaling factors.
          \param origin Origin for the transformations. */
      void createFromTransformations(const math::Vector2d& translation, double rotation, const math::Vector2d& scale, const math::Vector2d& origin = math::Vector2d(0.0, 0.0));

      //! Transform a point by the matrix.
      /*! \param pt The point to transform.
          \return A transformed point. */
      math::Vector2d transform(const math::Vector2d& pt) const;

      //! Returns the inverse of the matrix.
      /*! \return A new matrix which is the inverse of this. */
      math::Matrix3 getInverse() const;

      //! 0 based.
      double operator ()(uint32 row, uint32 col) const;

      //! 0 based.
      double& operator ()(uint32 row, uint32 col);

      //! Returns the result from multplying this and another matrix.
      math::Matrix3 operator *(const math::Matrix3& other) const;

      //! Multiples this matrix by another matrix, returning this.
      math::Matrix3& operator *=(const math::Matrix3& other);

      //! The identity matrix.
      static Matrix3 identity();


    private:

      double m_data[9];

    };

    #include "../../src/Math/Matrix3.inl"

  }
}

#endif